package ACWing.SearchAndGraphTheory.DFS;
//846. 树的重心
import java.util.Arrays;
import java.util.Scanner;
/**
 * @author :chenjie
 * @date :Created 2022/12/25 15:16
 */
public class CenterOFGravityOFTree {
    static int idx,n,ans;
    static int[]h=new int[100010];
    static int[]e=new int[100010*2];
    static int[]ne=new int[100010];
    static boolean[]st=new boolean[100010];
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        n=sc.nextInt();
        Arrays.fill(h,-1);
        for (int i = 0; i < n-1; i++) {
            int a=sc.nextInt();
            int b=sc.nextInt();
            add(a,b);
            add(b,a);
        }

        ans=n;dfs(1);
        System.out.println(ans);

    }

    /**
     * 非常优雅非常优雅啊
     * 思路将链式关系压缩再ne的数组里头可以根据i=ne【i】的值来确定下一个点的下标而因为是头插法所以只要有点进来我就更新坐标并且将上一个点的下标保存在ne中
     * @param a
     * @param b
     */
    public static void add(int a,int b){
        e[idx] = b;
        ne[idx] = h[a];
        h[a] = idx ++ ;
    }
    public static int dfs(int u){
        st[u] = true;

        int size = 0, sum = 0;
        for (int i = h[u]; i != -1; i = ne[i])
        {
            int j = e[i];
            if (st[j]) continue;

            int s = dfs(j);
            size = Math.max(size, s);
            sum += s;
        }

        size = Math.max(size, n - sum - 1);
        ans = Math.min(ans, size);

        return sum + 1;

    }
}
